package com.siloam.service;

import java.util.ArrayList;
import java.util.List;

import org.springframework.transaction.annotation.Transactional;

import com.siloam.dao.RoleDao;
import com.siloam.module.Role;
import com.siloam.vo.RoleVO;

public class RoleService {

	private RoleDao roleDao;
	
	public RoleDao getRoleDao() {
		return roleDao;
	}

	public void setRoleDao(RoleDao roleDao) {
		this.roleDao = roleDao;
	}

	@Transactional
	public void add(Role role){
		roleDao.add(role);
	}
	
	@Transactional
	public void update(Role role){
		roleDao.update(role);
	}
	
	@Transactional
	public void delete(String ids){
		roleDao.delete(ids);
	}
	
	public Role load(int id){
		return roleDao.load(id);
	}
	
	public List<RoleVO> findAll(){
		List<Role> roles = roleDao.findAll();
		List<RoleVO> roleVOs = new ArrayList<RoleVO>();
		for(Role role : roles){
			roleVOs.add(new RoleVO(role));
		}
		return roleVOs;
	}
	
}
